/**
 * Created by Administrator on 2017/5/5 0005.
 */
checkCookie()
var mid= $.cookie('mid')
var token= $.cookie('token')
var next_page='';
var data_back=false
$(window).scroll(function () {
    var windowheight=$(window).height();//窗口高度
    var scrolltop=$('body').scrollTop();//滚动条高度
    var eh=$(document).height();//文本高度
    if(eh==windowheight+scrolltop){
        $('.bot_loading').show()
            if(data_back){
                return false
            }
        data_back=true;
            if(next_page==null){
                $('.bot_loading').html('没有更多啦！');
                setInterval(function () {
                    $('.bot_loading').fadeOut(800)
                },2000);
                data_back=false
            }else{
                getData({url:next_page,data:{mid:mid,token:token}}, function (data) {
                    var html=template('list',data);
                    $('.list').append(html)
                    $('.bot_loading').hide();
                    next_page=data.next_page_url;
                    data_back=false
              })
            }

    }else{
        $('.bot_loading').hide()
    }
})
getData({url:follow_list,data:{mid:mid,token:token}}, function (data) {
    var html=template('list',data)
    $('.list').html(html);
    next_page=data.next_page_url;
    var childs=$('.list').find('.one')
    if(childs.length==0){
        $('.list').append('<p style="text-align: center;padding-top: 10px;font-size:15px; line-height: 360px; color: #666;">暂无关注</p>')
    }
    $('.one').on('touchstart', function () {
            var id=$(this).attr('d_id')
          window.location.href='doctor_info.html?d_id='+id;
    })
    //取消关注
    $('.quxiao').on('touchstart', function (e) {
        e.stopPropagation();
       var id=$(this).attr('d_id');
        var list=$(this).parents('.one');
        getData({url:cancle_follow,data:{mid:mid,token:token,id:id}}, function () {
            creatLayout('取消成功!');
            list.hide()
        })
    })
})
